home *** CD-ROM | disk | FTP | other *** search
- package Local.Game.Thing
- {
- import STC9.Math.CLineIntersection;
- import flash.display.*;
- import flash.events.*;
- import flash.geom.*;
- import flash.utils.getTimer;
-
- public class CPath
- {
-
-
- private var mPathIndex:Number;
-
- private var mPath:Array;
-
- private var pPath:Array;
-
- private var mPathLength:Number;
-
- public function CPath()
- {
- super();
- mPathLength = 0;
- mPathIndex = 0;
- mPath = new Array();
- pPath = new Array();
- }
-
- public function get mPoint() : Point
- {
- var _loc1_:Object = null;
- var _loc2_:Number = NaN;
- _loc1_ = mPath[Math.floor(mPathIndex)];
- _loc2_ = mPathIndex % 1;
- return new Point(_loc1_.p1.x + _loc1_.d.x * _loc2_,_loc1_.p1.y + _loc1_.d.y * _loc2_);
- }
-
- public function get mRadians() : Number
- {
- var _loc1_:int = 0;
- var _loc2_:Number = NaN;
- var _loc3_:Object = null;
- var _loc4_:Object = null;
- if(true)
- {
- _loc1_ = Math.floor(mPathIndex);
- _loc2_ = mPathIndex % 1;
- }
- _loc3_ = mPath[_loc1_];
- §§push((_loc4_ = mPath[_loc1_ == mPath.length - 1 ? _loc1_ : _loc1_ + 1]).rads - _loc3_.rads);
- if(true)
- {
- §§push(§§pop() * _loc2_);
- }
- return §§pop() + _loc3_.rads;
- }
-
- public function SetPath_PD2(param1:Point, param2:Point, param3:Point, param4:Point = null) : void
- {
- var _loc5_:Point = null;
- param4 = param4 == null ? new Point(-param2.x,param2.y) : param4;
- if((_loc5_ = CLineIntersection.InfinatePD(param1,param2,param3,param4)) == null)
- {
- return;
- }
- SetPath([param1,_loc5_,param3]);
- }
-
- public function OrientateThing(param1:CThingMain) : void
- {
- var _loc2_:int = 0;
- var _loc3_:Number = NaN;
- var _loc4_:Object = null;
- var _loc5_:Object = null;
- _loc2_ = Math.floor(mPathIndex);
- _loc3_ = mPathIndex % 1;
- _loc4_ = mPath[_loc2_];
- _loc5_ = mPath[_loc2_ == mPath.length - 1 ? _loc2_ : _loc2_ + 1];
- if(true)
- {
- param1.mPosition.x = _loc4_.p1.x + _loc4_.d.x * _loc3_;
- if(true)
- {
- param1.mPosition.y = _loc4_.p1.y + _loc4_.d.y * _loc3_;
- if(true)
- {
- param1.mAngle.mAngleRAD = (_loc5_.rads - _loc4_.rads) * _loc3_ + _loc4_.rads;
- }
- if(param1.mOrientation == -1)
- {
- }
- §§goto(addr114);
- }
- param1.mAngle.InvertOrientation();
- }
- addr114:
- }
-
- public function DrawPath(param1:Graphics) : void
- {
- var _loc2_:int = 0;
- _loc2_ = 0;
- while(_loc2_ < mPath.length)
- {
- param1.moveTo(mPath[_loc2_].p1.x,mPath[_loc2_].p1.y);
- if(false)
- {
- break;
- }
- param1.lineTo(mPath[_loc2_].p2.x,mPath[_loc2_].p2.y);
- if(true)
- {
- _loc2_ += 2;
- }
- }
- }
-
- public function get mDelta() : Point
- {
- return Point.polar(1,mRadians);
- }
-
- public function MoveAlong(param1:Number) : Boolean
- {
- var _loc2_:Number = NaN;
- var _loc3_:Number = NaN;
- loop0:
- while(true)
- {
- §§push(param1);
- §§push(0);
- while(true)
- {
- if(§§pop() <= §§pop())
- {
- §§push(true);
- break;
- }
- _loc2_ = Number(mPath[Math.floor(mPathIndex)].len);
- §§push(_loc2_);
- §§push(1);
- if(false)
- {
- continue;
- }
- §§push(mPathIndex);
- if(true)
- {
- §§push(§§pop() % 1);
- }
- §§push(§§pop() - §§pop());
- if(true)
- {
- _loc3_ = §§pop() * §§pop();
- if(param1 > _loc2_)
- {
- mPathIndex = Math.floor(mPathIndex) + 1;
- addr57:
- param1 -= _loc2_;
- }
- else
- {
- §§push(§§findproperty(mPathIndex));
- §§push(mPathIndex);
- if(true)
- {
- §§push(param1);
- if(true)
- {
- §§push(§§pop() / _loc2_);
- }
- §§push(§§pop() + §§pop());
- }
- §§pop().mPathIndex = §§pop();
- param1 = 0;
- }
- if(mPathIndex >= mPath.length)
- {
- §§push(false);
- if(true)
- {
- return §§pop();
- }
- break;
- }
- continue loop0;
- }
- §§goto(addr57);
- }
- return §§pop();
- }
- }
-
- public function SetPath(param1:Array) : void
- {
- var _loc2_:Number = NaN;
- var _loc3_:int = 0;
- var _loc4_:Object = null;
- _loc2_ = getTimer();
- _loc3_ = 0;
- loop0:
- while(true)
- {
- §§push(_loc3_);
- §§push(param1.length - 1);
- if(false)
- {
- break;
- }
- if(§§pop() >= §§pop())
- {
- _loc3_ = 0;
- while(true)
- {
- §§push(_loc3_);
- §§push(pPath.length - 1);
- break loop0;
- addr62:
- _loc4_ = {
- "p1":pPath[_loc3_ + 0],
- "p2":pPath[_loc3_ + 1]
- };
- _loc4_.d = _loc4_.p2.subtract(_loc4_.p1);
- _loc4_.len = _loc4_.d.length;
- _loc4_.rads = GetRADS(_loc4_.d);
- mPathLength += _loc4_.len;
- if(_loc4_.len >= 1)
- {
- mPath.push(_loc4_);
- }
- _loc3_++;
- }
- §§goto(addr123);
- }
- GeneratePath(param1[_loc3_],param1[_loc3_ + 1],param1[_loc3_ + 2],25);
- _loc3_ += 2;
- }
- while(true)
- {
- if(§§pop() < §§pop())
- {
- §§goto(addr62);
- }
- addr123:
- return;
- }
- }
-
- private function GetRADS(param1:Point) : Number
- {
- var _loc2_:* = NaN;
- §§push(Math.atan2(param1.y,param1.x));
- if(true)
- {
- _loc2_ = §§pop();
- §§push(_loc2_);
- if(true)
- {
- if(§§pop() < 0)
- {
- §§goto(addr52);
- }
- else
- {
- §§push(_loc2_);
- }
- §§goto(addr52);
- }
- §§push(§§pop());
- }
- addr52:
- §§push(_loc2_);
- if(true)
- {
- §§push(§§pop() + Math.PI * 2);
- }
- return §§pop();
- }
-
- public function GeneratePath(param1:Point, param2:Point, param3:Point, param4:Number) : void
- {
- var _loc5_:Point = null;
- var _loc6_:Point = null;
- var _loc7_:Number = NaN;
- var _loc8_:Number = NaN;
- var _loc9_:Number = NaN;
- var _loc10_:Point = null;
- var _loc11_:Point = null;
- var _loc12_:int = 0;
- _loc5_ = param2.subtract(param1);
- _loc6_ = param3.subtract(param2);
- if(true)
- {
- _loc7_ = _loc5_.length;
- if(true)
- {
- _loc8_ = _loc6_.length;
- }
- _loc9_ = Math.ceil((_loc7_ > _loc8_ ? _loc7_ : _loc8_) / param4);
- }
- _loc10_ = param1.clone();
- _loc11_ = param2.clone();
- _loc5_.x /= _loc9_;
- _loc5_.y /= _loc9_;
- _loc6_.x /= _loc9_;
- _loc6_.y /= _loc9_;
- _loc12_ = 0;
- while(_loc12_ <= _loc9_)
- {
- pPath.push(new Point((_loc11_.x - _loc10_.x) * _loc12_ / _loc9_ + _loc10_.x,(_loc11_.y - _loc10_.y) * _loc12_ / _loc9_ + _loc10_.y));
- _loc12_++;
- _loc10_.x += _loc5_.x;
- _loc10_.y += _loc5_.y;
- _loc11_.x += _loc6_.x;
- _loc11_.y += _loc6_.y;
- }
- }
- }
- }
-